package com.justech.eat.service.impl;

import com.justech.common.util.MesAssert;
import com.justech.eat.entity.Config;
import com.justech.eat.repository.ConfigRepository;
import com.justech.eat.service.ConfigService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @program: eat-service
 * @description:
 * @author: feifei.li
 * @create: 2020-06-10 09:14
 **/
@Service
public class ConfigServiceImpl implements ConfigService {

    @Autowired
    ConfigRepository configRepository;

    @Override
    public Config get(String key) {
        MesAssert.isTrue((StringUtils.isBlank(key)), "key Must not be empty");
        Config byKey = configRepository.findByKey(key);
        if (byKey == null) {
            MesAssert.throwBizException("未发现用户数据源的接口地址");
        }
        return byKey;
    }
}
